{% extends 'myadmin/base.html' %}
{% block main_body %}
<style>
    .form-card {
        background: #fff;
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        padding: 20px;
    }
    .form-section {
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #f1f1f1;
    }
    .form-row {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -10px;
    }
    .form-col {
        flex: 1;
        min-width: 300px;
        padding: 0 10px;
        box-sizing: border-box;
    }
    .form-group {
        margin-bottom: 12px;
        width: 100%;
    }
    .form-group label {
        font-weight: 600;
        font-size: 13px;
        margin-bottom: 5px;
        display: block;
    }
    .form-control {
        width: 100%;
        padding: 6px 10px;
        font-size: 13px;
        height: 34px;
        box-sizing: border-box;
    }
    textarea.form-control {
        height: auto;
        min-height: 120px;
    }
    .checkbox-group {
        display: flex;
        gap: 15px;
        margin-top: 8px;
    }
    .checkbox-item {
        display: flex;
        align-items: center;
        gap: 5px;
    }
    .btn-group {
        margin-top: 15px;
        display: flex;
        gap: 10px;
        justify-content: flex-end;
    }
    .required-mark {
        color: #dd4b39;
        margin-left: 3px;
    }
</style>

<section class="content-header">
    <h1>系统管理 <small>编辑通知</small></h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-home"></i> 首页</a></li>
        <li><a href="#">系统管理</a></li>
        <li><a href="{% url 'myadmin_systemnotice_index' 1 %}">通知列表</a></li>
        <li class="active">编辑通知</li>
    </ol>
</section>

<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">编辑通知信息</h3>
                </div>
                <form method="post" action="{% url 'myadmin_systemnotice_update' notice.notice_id %}" class="form-card">
                    {% csrf_token %}
                    
                    <!-- 基本信息 -->
                    <div class="form-section">
                        <h4><i class="fa fa-bullhorn"></i> 通知基本信息</h4>
                        <div class="form-row">
                            <div class="form-col">
                                <div class="form-group">
                                    <label>通知ID</label>
                                    <input type="text" value="{{ notice.notice_id }}" class="form-control" disabled>
                                </div>
                                <div class="form-group">
                                    <label>通知标题 <span class="required-mark">*</span></label>
                                    <input type="text" name="title" value="{{ notice.title }}" class="form-control" required>
                                </div>
                                <div class="form-group">
                                    <label>通知类型 <span class="required-mark">*</span></label>
                                    <select name="notice_type" class="form-control" required>
                                        {% for type in notice_types %}
                                        <option value="{{ type.0 }}" {% if notice.notice_type == type.0 %}selected{% endif %}>
                                            {{ type.1 }}
                                        </option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                            <div class="form-col">
                                <div class="form-group">
                                    <label>创建时间</label>
                                    <input type="text" value="{{ notice.create_time|date:'Y-m-d H:i:s' }}" class="form-control" disabled>
                                </div>
                                <div class="form-group">
                                    <label>过期时间</label>
                                    <input type="datetime-local" name="expire_time" 
                                           value="{{ notice.expire_time|date:'Y-m-d\TH:i:s' }}" 
                                           class="form-control">
                                    <small class="text-muted">留空表示永久有效</small>
                                </div>
                                <div class="form-group">
                                    <label>通知状态</label>
                                    <div class="checkbox-group">
                                        <div class="checkbox-item">
                                            <input type="checkbox" name="is_active" id="isActive" 
                                                   {% if notice.is_active %}checked{% endif %}>
                                            <label for="isActive">启用通知</label>
                                        </div>
                                        <div class="checkbox-item">
                                            <input type="checkbox" name="is_important" id="isImportant"
                                                   {% if notice.is_important %}checked{% endif %}>
                                            <label for="isImportant">标记为重要</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 通知内容 -->
                    <div class="form-section">
                        <h4><i class="fa fa-file-text"></i> 通知内容</h4>
                        <div class="form-row">
                            <div class="form-col">
                                <div class="form-group">
                                    <label>内容详情 <span class="required-mark">*</span></label>
                                    <textarea name="content" class="form-control" rows="6" required>{{ notice.content }}</textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 操作按钮 -->
                    <div class="btn-group">
                        <button type="button" class="btn btn-default" onclick="window.history.back();">返回</button>
                        <button type="reset" class="btn btn-default">重置</button>
                        <button type="submit" class="btn btn-primary">保存修改</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
{% endblock %}